After completing this lesson, you'll be able to:
In the past exercise, you created a new community map dataset for the planning department using a dynamic schema. We defined only two tables at the time, but now another is required, and the planning department wants you to update the workspace.
Rather than making changes each time they add more datasets, you believe you can create an Excel spreadsheet containing the schema definition. That way, the planning team can edit it themselves and do the same for all future updates.
Open and examine the spreadsheet CommunityMapSchema.xlsx (or C:\FMEData\Resources\DesktopAdvanced\CommunityMapSchema.xlsx).
If you don't have Excel, open it in the FME Data Inspector and switch to Table View.
The table has schema definitions for Firehalls, Parks, and Zones feature types. You can see how each new table has a series of attributes defined for it (each attribute is a separate row in the spreadsheet), including attribute type and attribute order. Geometry type only needs to be defined once per table.
Start FME Workbench (2022.1 or later). Open the workspace from the previous exercise or the starting workspace.
Because we are using a spreadsheet to define our output schemas, the CommunityMap Resource Reader is no longer needed. Locate it in the Navigator window, right-click it, and choose Delete.
When prompted, click Yes to confirm that FME will remove all references to this dataset.
Now select Readers > Add Reader as Resource. In the dialog that opens, choose:
Reader Format | Schema (From Table) |
Reader Dataset | https://s3.amazonaws.com/FMEData/FMEData/Resources/DesktopAdvanced/CommunityMapAdvancedSchema.xlsx or C:\FMEData\Resources\DesktopAdvanced\CommunityMapSchema.xlsx |
Click the Parameters button (OK will be greyed-out until you do). This dialog is where we can define how the table maps to the required schema.
Check the reader parameters at the top. They should show the dataset is an Excel format file. Select Sheet1 under the Select Table parameter if it is not already selected:
The first row should get used as the field names. If this is not the case, then click the parameters button above and set the values correctly:
Next, select the appropriate fields to match the required parameters (for example, Feature Type = FeatureType):
Click OK to close the dialog and again to add the resource reader.
Now inspect the feature type parameters for the writer feature type.
Under the User Attributes tab, remove the LastUpdatedBy attribute, as we've added this to the spreadsheet definition for each type and no longer need it here.
In the Parameters tab, click the Schema Sources edit button. Uncheck FireHalls and check CommunityMapSchema [SCHEMA_FROM_TABLE]:
Accept the changes to these parameters.
If you noticed, the schema spreadsheet included an entry for the Zones dataset, so add a reader (not a Resource – we want the data this time) as follows:
Reader Format | MapInfo TAB (MITAB) |
Reader Dataset | https://s3.amazonaws.com/FMEData/FMEData/Data/Zoning.zip or C:\FMEData\Data\Zoning\Zones.tab |
Once added, connect its reader feature type to the dynamic writer feature type.
Save the workspace and then run it.
Inspect the output. Notice that FME has written all three feature types, and their attribute schema matches what we defined in the Excel spreadsheet, including the LastUpdatedBy field for each one.
However, we still have not instructed FME on how to link the new, externally defined schema and the existing one. For this reason, all of the new attributes defined in the external schema table have missing values in the output data. We'll examine how to address this issue using the SchemaMapper in the next exercise.
Before we address the schema mapping issue, let's try using a FeatureReader and schema feature to define the output schema in a dynamic workspace.
We'll keep the existing objects in the workspace and use them in the next exercise. But let's add a new Creator and FeatureReader to show a different way to configure a dynamic workspace.
Connect the Creator to the FeatureReader and configure the FeatureReader like this:
Reader Format | MapInfo TAB (MITAB) |
Reader Dataset | https://s3.amazonaws.com/FMEData/FMEData/Data/Zoning.zip,https://s3.amazonaws.com/FMEData/FMEData/Data/Parks.zip or C:\FMEData\Data\Zoning\Zones.tab,C:\FMEData\Data\Parks\Parks.tab |
Output Ports | Single Output Port |
Click OK and run your workspace. This section of your workspace should look like this:
If you inspect the output ports, you will notice two things:
We can use these two sets of features to write our data using a generic writer.
Use Writers > Add Writer to add a writer. Configure it like this:
Writer Format | OGC GML (Geography Markup Language) |
Writer Dataset | C:\FMEData\Output\Training\NewCommunityMapSchemaFeature.gml |
Feature Type Definition | Dynamic (Advanced) |
Click OK to add the writer feature type. Move it next to your FeatureReader and connect it to the <Schema> and <Generic> ports.
Double-click the writer feature type. You will see that it is automatically configured to use the fme_feature_type attribute to define the destination feature type names. That is correct. However, it is currently using the readers as Schema Sources. Click the ellipsis next to Schema Sources and choose only Schema From Schema Feature.
Click OK twice to close the dialogs.
Rerun the entire workspace. Inspect the output of the <Dynamic> writer feature type you just configured. You will find both the Parks and Zoning layers written out to GML with their original schemas.